package com.ysw.validator.dynamic_validator;

import lombok.Data;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @ClassName Employee
 * @Description 员工   性别是男 年龄就必须大于20，女的话就 大于18
 *
 *  年龄是由性别来决定的
 * @Author ysw
 * @Date 2022/5/13 20:20
 */
@Data
@GroupSequenceProvider(value = EmployeeGroupSequeceProvider.class)
public class Employee {
    @NotNull
    @Max(value = 10,groups = {UpdateGroup.class})
    private Integer sex;

    @NotNull
    @Min(value = 18,groups = {GirlGroup.class})
    @Min(value = 20,groups = {BoyGroup.class})
    private Integer age;
    @NotBlank(groups = {GirlGroup.class})
    private String name;

    /**
     * 用来动态
     */
    public interface GirlGroup{}
    public interface BoyGroup{}

    public interface UpdateGroup{}

}